<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<c:set var="menuId" value="${menuId}" />
<c:set var="menuParentId" value="${menuParentId}" />

<c:forEach  var="loginUserMenu" items="${loginUserMenus}">
	<c:choose>
		<c:when test="${fn:length(loginUserMenu.childs) eq 0}">
			<c:choose>
				<c:when test="${(loginUserMenu.id eq menuId) and (loginUserMenu.parentId eq menuParentId)}">
					<li class="active">
						<a data-level="${loginUserMenu.level}" data-childs="${fn:length(loginUserMenu.childs)}" href="<%=basePath%>${loginUserMenu.url}">
							<i class="menu-icon iconfont ${loginUserMenu.icon}"></i>
							<span class="menu-text">${loginUserMenu.name}</span>
						</a>
					
						<b class="arrow"></b>
					</li>
				</c:when>
				<c:otherwise>
					<li class="">
						<a data-level="${loginUserMenu.level}" data-childs="${fn:length(loginUserMenu.childs)}" href="<%=basePath%>${loginUserMenu.url}">
							<i class="menu-icon iconfont ${loginUserMenu.icon}"></i>
							<span class="menu-text">${loginUserMenu.name}</span>
						</a>
					
						<b class="arrow"></b>
					</li>
				</c:otherwise>
			</c:choose>
		</c:when>
		<c:otherwise>
			<li>
				<c:choose>
					<c:when test="${loginUserMenu.id eq  menuParentId}">
						<li class="open">
							<a class="main-menu dropdown-toggle" data-level="${loginUserMenu.level}" data-childs="${fn:length(loginUserMenu.childs)}" href="javascript:void(0);">
								<i class="menu-icon iconfont ${loginUserMenu.icon}"></i>
								<span class="menu-text">${loginUserMenu.name}</span>
						
								<b class="arrow fa fa-angle-up"></b>
							</a>
						
							<b class="arrow"></b>
						
							<ul class="submenu">
								<c:forEach  var="child" items="${loginUserMenu.childs}">
									<c:choose>
										<c:when test="${child.id eq menuId}">
											<li class="active">
												<a data-level="${child.level}" data-childs="${fn:length(child.childs)}" href="<%=basePath%>${child.url}">
													<i class="menu-icon iconfont ${child.icon}"></i>${child.name}
												</a>
									
												<b class="arrow"></b>
											</li>
										</c:when>
										<c:otherwise>
											<li class="">
												<a data-level="${child.level}" data-childs="${fn:length(child.childs)}" href="<%=basePath%>${child.url}">
													<i class="menu-icon iconfont ${child.icon}"></i>${child.name}
												</a>
									
												<b class="arrow"></b>
											</li>
										</c:otherwise>
									</c:choose>
								</c:forEach>
							</ul>
						</li>
					</c:when>
					<c:otherwise>
						<li class="">
							<a class="main-menu dropdown-toggle" data-level="${loginUserMenu.level}" data-childs="${fn:length(loginUserMenu.childs)}" href="javascript:void(0);">
								<i class="menu-icon iconfont ${loginUserMenu.icon}"></i>
								<span class="menu-text">${loginUserMenu.name}</span>
						
								<b class="arrow fa fa-angle-down"></b>
							</a>
						
							<b class="arrow"></b>
						
							<ul class="submenu">
								<c:forEach  var="child" items="${loginUserMenu.childs}">
									<li class="">
										<a data-level="${child.level}" data-childs="${fn:length(child.childs)}" href="<%=basePath%>${child.url}">
											<i class="menu-icon iconfont ${child.icon}"></i>${child.name}
										</a>
							
										<b class="arrow"></b>
									</li>
								</c:forEach>
							</ul>
						</li>
					</c:otherwise>
				</c:choose>
			</li>
		</c:otherwise>
	</c:choose>
</c:forEach>

<%-- 
<li class="">
	<a class="main-menu" data-id="1" data-level="1" data-child="0" href="<%=basePath%>index.html?menuId=0&menuParentId=0">
		<i class="menu-icon fa fa-tachometer"></i>
		<span class="menu-text">首页</span>
	</a>

	<b class="arrow"></b>
</li>

<li class="">
	<a data-id="1" data-level="1" data-child="0" href="javascript:void(0);" class="dropdown-toggle">
		<i class="menu-icon fa fa-desktop"></i>
		<span class="menu-text">
			一级菜单
		</span>

		<b class="arrow fa fa-angle-down"></b>
	</a>

	<b class="arrow"></b>

	<ul class="submenu">
		<li class="">
			<a class="main-menu" data-menuIndex="2" href="<%=basePath%>index.html?menuIndex=2">
				<i class="menu-icon fa fa-caret-right"></i>
				二级菜单
			</a>

			<b class="arrow"></b>
		</li>
	</ul>
</li>
--%>